﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using WF_TheTourManagement.EntityClass;

namespace WF_TheTourManagement
{
    class TourType
    {
        public int tourTypeId;
        public string tourTypeName;
        string tourTypeDesCription;
        SqlConnection connection;

        public TourType() { }

        public TourType(TourType _tourtype)
        {
            this.tourTypeId = _tourtype.tourTypeId;
            this.tourTypeName = _tourtype.tourTypeName;
            this.tourTypeDesCription = _tourtype.tourTypeDesCription;
        }
               

        private void getAllLocations()
        {
            DataTable dataTable = new DataTable("TourTypes");
            SqlDataAdapter dataAdapter = new SqlDataAdapter();

            SqlCommand sqlCmd = new SqlCommand();
            sqlCmd.Connection = connection;

            //Cach 1: dung cau van tru tiep
            //sqlCmd.CommandType = CommandType.Text;
            //sqlCmd.CommandText = @"select * from names";
            //da.SelectCommand = sqlCmd;
            //da.Fill(dt);

            //Cach 2: thuc hien thong qua Stored Procedure
            sqlCmd.CommandType = CommandType.StoredProcedure;
            sqlCmd.CommandText = "getAllLocations";
            SqlDataReader daReader = sqlCmd.ExecuteReader();
            dataTable.Load(daReader);
        }

        public DataTable allTourTypes()
        {
            DataTable dt = new DataTable();

            SqlCommand sqlCmd = new SqlCommand();
            sqlCmd.Connection = DataConnection.Connection();

            sqlCmd.CommandType = CommandType.StoredProcedure;
            sqlCmd.CommandText = "getAllTourTypes";
            SqlDataReader daReader = sqlCmd.ExecuteReader();
            dt.Load(daReader);
            return dt;
        }


    }
}
